package lobystate
{
	import flash.events.Event;
	
	import mx.core.FlexGlobals;
	
	import spark.components.Scroller;
//	import spark.components.supportClasses.ScrollBar;

	public class StateGetTableInfo extends NetRequestState
	{
		private static var instance:StateGetTableInfo = null;
		
		// 用来记录玩家当前所在的大厅的游戏类型编号
		public var gameRoomGid:int;
		
		private var nPage:int;
		
		public function StateGetTableInfo()
		{
			super();
			nPage = 0;
		}

		public static function get Instance():StateGetTableInfo
		{
			if(instance == null)
				instance = new StateGetTableInfo();
			return instance;
		}
		
		// override function
		override public function send(obj:StateManager):void
		{
			// 显示进行过程
			LobyNetManager.Instance.showNetProcess("获得大厅内游戏桌信息中……");

			/*var tree:XML = LobyManager.Instance.TreeData;
			var node:XMLList = tree..*.(@lid == StateGetPlayerInfo.Instance.lastSuccData.player.lid);*/
			LobyNetManager.Instance.httpservice.url = LobyNetManager.URL_lobyAddress;
			// 第一次的时候默认会请求page 第一页的内容
			LobyNetManager.Instance.httpservice.request = {"PROCESS":LobyNetManager.URL_tableInfo,"page":nPage};
			LobyNetManager.Instance.httpservice.send();
			// 设置lobysonaddress，该房间内的桌子请求都向这个地址发送
			//LobyNetManager.URL_lobysonAddress = node.@address;
		}
		override public function receive(obj:Object):Boolean
		{
			if(super.receive(obj))
			{
				trace(obj.toString());		
	
				LobyNetManager.Instance.tabledata = obj;
				LobyManager.Instance.getintoRoom(obj);
				// 请求玩家列表
				LobyNetManager.Instance.send(LobyNetManager.getRoomPlayerlist);
				// 当成功请求了一次游戏桌数据之后，将得到的值赋值给更新部分StateUpdateRoomTable		

				// 关闭进行过程
				LobyNetManager.Instance.closeNetProcess();
				return true;
			}	
			return false;
		}
		override public function fault(event:Event):void
		{
			// 关闭进行过程
			LobyNetManager.Instance.closeNetProcess();
		}
		
		public function setPage(val:int):void
		{
			nPage = val;
		}
	}
}